import React, { useEffect, useState } from 'react'
import './Strict.less';

export default function Strict() {
  //简单的输出
  // console.log('222');
  //为 window 绑定单击事件
  // window.addEventListener('click', function(){
  //   console.log('run run run');
  // });
  let [count, setCount] = useState(0);
  //启动定时器
  useEffect(() => {
    let timer = setInterval(() => {
      // console.log('run run run');
      setCount(count => count + 1);
    }, 1000);

    //清理
    return () => {
      clearInterval(timer);
    }
  }, [])
  return (
    <h2>{count}</h2>
  )
}
